#pragma once

#include <functional>
#include <string>

class Task
{
public:
    typedef std::function<int(int, int, char)> func_t;

public:
    Task()
    {
    }

    Task(int x, int y, char op, func_t callback)
        : _x(x), _y(y), _op(op), _callback(callback)
    {
    }

    //供消费者调用，打印任务结果
    int operator()()
    {
        int result = _callback(_x, _y, _op);
        return result;
    }

    //供生产者调用，打印任务
    std::string taskToString()
    {
        char buf[1024];
        snprintf(buf,sizeof(buf),"%d %c %d = ?",_x,_op,_y);
        return buf;
    }

private:
    int _x;
    int _y;
    char _op;
    func_t _callback;
    
};